package com.foreveross.vo;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

import com.foreveross.util.NotSerialize;

@Entity
@Table(name = "news_houses", catalog = "hrtenement")
public class NewsHouse implements java.io.Serializable {

	private String id;

	private HrHouses house;

	@NotSerialize
	private HrNewsInfo hrNewsInfo;

	public NewsHouse() {
	}

	public NewsHouse(String id) {
		this.id = id;
	}
	
	public NewsHouse(HrHouses house, HrNewsInfo hrNewsInfo) {
		this.house = house;
		this.hrNewsInfo = hrNewsInfo;
	}

	public NewsHouse(String id, HrHouses house, HrNewsInfo hrNewsInfo) {
		this.id = id;
		this.house = house;
		this.hrNewsInfo = hrNewsInfo;
	}

	@Id
	@GenericGenerator(name = "idGenerator", strategy = "uuid")
	@GeneratedValue(generator = "idGenerator")
	@Column(name = "id", unique = true, nullable = false, length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "house_id")
	@NotFound(action=NotFoundAction.IGNORE)
	public HrHouses getHouse() {
		return this.house;
	}

	public void setHouse(HrHouses house) {
		this.house = house;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "news_id")
	@NotFound(action=NotFoundAction.IGNORE)
	public HrNewsInfo getHrNewsInfo() {
		return this.hrNewsInfo;
	}

	public void setHrNewsInfo(HrNewsInfo hrNewsInfo) {
		this.hrNewsInfo = hrNewsInfo;
	}
	
}
